package cn.francis.chatplatform.modules.message.controller;


import jakarta.annotation.Resource;
import lombok.RequiredArgsConstructor;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.zhipuai.ZhiPuAiChatModel;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author 张俊辉
 */

@RestController
@RequiredArgsConstructor
public class CommunicateSpringController {

    private final ZhiPuAiChatModel chatModel;
    @GetMapping("/ai/generate")
    public void execute(@RequestParam(value = "message", defaultValue = "你好") String message) {
        Map<String, String> generation = Map.of("generation", this.chatModel.call(message));
        System.out.println(generation);
    }
}
